Skip to content

complete task#1781

Open
OlenaShtronda wants to merge 1 commit into
mate-academy:masterfrom
OlenaShtronda:master
Open

complete task#1781
OlenaShtronda wants to merge 1 commit into
mate-academy:masterfrom
OlenaShtronda:master

Conversation

@OlenaShtronda
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I am requesting changes because there are still a couple of checklist violations, even though your ArrayList implementation is functionally correct and well structured. The first issue is the magic number in the growth logic: on line 99 you use size + size / 2 with a hardcoded 2, which violates the requirement that any magic numbers should be constants [CHECKLIST ITEM #X]; please extract this divisor or factor into a clearly named constant (for example, private static final int GROWTH_DIVISOR = 2;) and ideally compute the new capacity from elementData.length for clarity (e.g., int newCapacity = elementData.length + elementData.length / GROWTH_DIVISOR;). The second issue is stylistic but still tied to the checklist: several constructors/methods (for example, the constructor starting around line 8 in ArrayList.java) begin with an empty line, which goes against the item that says not to start a class or method body with a blank line; remove those leading blank lines so the implementation starts immediately after the opening brace. These are the only blocking problems I see: your handling of default capacity, 1.5x growth, index checks, System.arraycopy, and exception behavior all correctly match the task requirements. Once you promote the magic number to a constant and clean up the initial blank lines in method/constructor bodies, your solution will fully satisfy both the functional and checklist expectations. You are very close—fixing these small but important details will bring your implementation fully in line with production-quality style standards.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/main/java/core/basesyntax/ArrayList.java
Comment thread src/main/java/core/basesyntax/ArrayList.java Outdated
Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Your solution is approved and meets all the specified requirements for the custom ArrayList implementation. You correctly implement the List<T> interface with all required methods (add, add(index), addAll, get, set, remove, size, isEmpty), use a default capacity of 10, and grow the internal array by 1.5x using a named constant while relying on System.arraycopy for element shifting. Index validation is cleanly centralized in a helper method that consistently throws the custom ArrayListIndexOutOfBoundsException, and remove(T element) properly throws an informative NoSuchElementException when the element is not found. There are no functional or checklist-blocking issues; behavior and error handling align well with the task requirements. As a minor optimization, you could enhance addAll by precomputing the final required capacity and growing the backing array once before the loop, instead of potentially growing multiple times while adding many elements. Overall, this is a clear, well-structured implementation that demonstrates good attention to both correctness and code quality—nicely done.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants